package com.heyun.controller;

import org.springframework.ai.moonshot.MoonshotChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 *  接入kimi
 */
@RestController
@RequestMapping("/kimi")
public class KimiChatController {

    private final MoonshotChatModel chatModel;

    @Autowired
    public KimiChatController(MoonshotChatModel chatModel) {
        this.chatModel = chatModel;
    }

    /**
     * kimiApi调用接口
     * @param message
     * @return
     */
    @GetMapping("/chat")
    public Map<String, String> chat(@RequestParam(value = "message", defaultValue = "Hello, Kimi!") String message) {
        String response = chatModel.call(message);
        return Map.of("response", response);
    }
}